<template>
	<view class="">
		<view class="">
			<tn-nav-bar fixed :isBack="false" :bottomShadow="false">我的设计</tn-nav-bar>
			<view class="discovery tn-safe-area-inset-bottom" :style="{paddingTop: vuex_custom_bar_height + 'px'}">
				<view class="" v-if="current==0">
					<view class="" style="padding: 30rpx 20rpx;">
						<waterfall ref="waterfall" v-model="list" @finish="handleWaterFallFinish">
							<template v-slot:left="{ leftList }">
								<view v-for="(item, index) in leftList" :key="index" class="product__item"
									@click="tn(`/pages/Posterproject/poster/index?myzuopinid=${item.id}`)">
									<view class="item__image" v-if="item.muban">
										<tn-lazy-load :threshold="-450" height="100%" :image="item.icon" :index="index"
											imgMode="widthFix"></tn-lazy-load>
									</view>
									<view class="item__data">
										<view class="item__title-container tn-text-center">
											<text class="item__title tn-color-cat">{{ item.muban.name }}</text>
										</view>
									</view>
									<view class="cha" @click.stop="todel(item.id)">
										<image class="btn_close" src="../../static/resource/cha.png" mode=""></image>
									</view>
								</view>
							</template>
							<template v-slot:right="{ rightList }">
								<view v-for="(item, index) in rightList" :key="index" class="product__item"
									@click="tn(`/pages/Posterproject/poster/index?myzuopinid=${item.id}`)">
									<view class="item__image" v-if="item.muban">
										<tn-lazy-load :threshold="-450" height="100%" :image="item.icon" :index="index"
											imgMode="widthFix"></tn-lazy-load>
									</view>
									<view class="item__data">
										<view class="item__title-container tn-text-center">
											<text class="item__title tn-color-cat">{{ item.muban.name }}</text>
										</view>
									</view>
									<view class="cha" @click.stop="todel(item.id)">
										<image class="btn_close" src="../../static/resource/cha.png" mode=""></image>
									</view>
								</view>
							</template>
						</waterfall>
					</view>
					<!-- <tn-load-more :status="loadStatus"></tn-load-more> -->
				</view>

				<view class="" v-if="current==1">
					<view class="" style="padding: 30rpx 20rpx;">
						<view class="tn-text-center" style="font-size: 200rpx;padding-top: 30rpx;">
							<text class="tn-icon-wea-wind tn-color-gray--light"></text>
						</view>
						<view class="tn-color-gray--disabled tn-text-center tn-text-lg">内容被台风吹走了1</view>
					</view>
				</view>
			</view>
		</view>
		<tabbar :currentIndex="3"></tabbar>
	</view>
</template>

<script>
	import {
		getdesignList
	} from '@/api/design/index.js'
	import {
		designlist,
		designdelete
	} from '@/api/poster/index.js'

	import tabbar from '@/components/tabbar/index.vue'
	import waterfall from '@/components/waterfall/index.vue'
	export default {
		components: {
			tabbar,
			waterfall
		},
		data() {
			return {
				cardCur: 0,
				swiperList: [],
				/* tabs*/
				current: 0,
				fixedList: [],
				/* 瀑布流*/
				loadStatus: 'loadmore',
				list: [],
				data: []
			}
		},
		onLoad() {

		},
		onShow() {
			const AccessToken = uni.getStorageSync('AccessToken')
			if (!AccessToken) {
				uni.showToast({
					icon:'none',
					title: '请登录',
					duration: 2000
				});
				return
			}
			this.getdesignlist()
		},
		methods: {
			todel(e){
				designdelete({
					id:e
				}).then((res) => {
					if(res.status == 200){
						this.$refs.waterfall.remove(e)
					}
				})
			},
			getdesignlist() {
				designlist().then((res) => {
					this.list = res.data.list
				})
			},
			// cardSwiper
			cardSwiper(e) {
				this.cardCur = e.detail.current
			},

			// 跳转
			tn(e) {
				uni.navigateTo({
					url: e,
				});
			},
			// tab选项卡切换
			tabChange(index) {
				this.current = index
			},
			/* 瀑布流*/
			// 获取随机数据
			getRandomData() {
				this.loadStatus = 'loading'
				for (let i = 0; i < 10; i++) {
					let index = this.$t.number.randomInt(0, this.data.length - 1)
					let item = JSON.parse(JSON.stringify(this.data[index]))
					let price = this.getPrice(item.price)
					item.id = this.$t.uuid()
					item.priceInteger = price[0]
					item.priceDecimal = price[1]
					this.list.push(item)
				}
			},
			// 瀑布流加载完毕事件
			handleWaterFallFinish() {
				this.loadStatus = 'loadmore'
			},
			// 获取价格整数和小数部分
			getPrice(price) {
				const priceStr = String(price)
				if (priceStr.indexOf('.') !== -1) {
					return priceStr.split('.')
				} else {
					return [priceStr, '00']
				}
			}
		}
	}
</script>

<style lang="scss" scoped>
	.discovery {
		min-height: 100vh;
	}

	/* 底部安全边距 start*/
	.tn-tabbar-height {
		min-height: 120rpx;
		height: calc(140rpx + env(safe-area-inset-bottom) / 2);
		height: calc(140rpx + constant(safe-area-inset-bottom));
	}

	/* 自定义导航栏内容 start */
	.custom-nav {
		height: 100%;

		&__back {
			margin-left: 30rpx;
			margin-top: 5rpx;
			font-size: 40rpx;
			flex-basis: 5%;
			width: 100rpx;
			position: absolute;
		}
	}

	/* 自定义导航栏内容 end */

	/* 轮播视觉差 start */
	.card-swiper {
		height: 800rpx !important;
	}

	.card-swiper swiper-item {
		width: 750rpx !important;
		left: 0rpx;
		box-sizing: border-box;
		// padding: 0rpx 30rpx 90rpx 30rpx;
		overflow: initial;
	}

	.card-swiper swiper-item .swiper-item {
		width: 100%;
		display: block;
		height: 100%;
		transform: scale(1);
		transition: all 0.2s ease-in 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item {
		transform: none;
		transition: all 0.2s ease-in 0s;
	}

	.card-swiper swiper-item .swiper-item-text {
		// background-color: rgba(0, 0, 0, 0.7);
		background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.05));
		margin-top: -260rpx;
		width: 100%;
		display: block;
		height: 50%;
		// border-radius: 10rpx;
		transform: translate(0rpx, 0rpx) scale(1);
		transition: all 0.6s ease 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item-text {
		// background-color: rgba(0, 0, 0, 0.7);
		background-image: linear-gradient(0deg, rgba(0, 0, 0, 0.7), rgba(0, 0, 0, 0.04));
		margin-top: -260rpx;
		width: 100%;
		transform: translate(0rpx, 0rpx) scale(1);
		transition: all 0.6s ease 0s;
	}


	.card-swiper swiper-item .swiper-item-title {
		transform: translate(50rpx, 0rpx) scale(0.9);
		transition: all 0.6s ease 0s;
		overflow: hidden;
	}

	.card-swiper swiper-item.cur .swiper-item-title {
		transform: translate(0rpx, 0rpx) scale(1);
		transition: all 0.6s ease 0s;
	}

	.image-banner {
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.image-banner image {
		width: 100%;
		height: 100%;
	}

	/* 轮播指示点 start*/
	.indication {
		z-index: 9999;
		width: 100%;
		height: 36rpx;
		position: absolute;
		display: flex;
		flex-direction: row;
		align-items: center;
		justify-content: center;
	}

	.spot {
		background-color: #FFFFFF;
		opacity: 0.6;
		width: 10rpx;
		height: 10rpx;
		border-radius: 20rpx;
		top: -60rpx;
		margin: 0 8rpx !important;
		position: relative;
	}

	.spot.active {
		opacity: 1;
		width: 30rpx;
		background-color: #FFFFFF;
	}

	/* 用户头像 start */
	.logo-image {
		width: 40rpx;
		height: 40rpx;
		position: relative;
	}

	.logo-pic {
		background-size: cover;
		background-repeat: no-repeat;
		// background-attachment:fixed;
		background-position: top;
		border: 1rpx solid rgba(255, 255, 255, 0.05);
		// box-shadow: 0rpx 0rpx 80rpx 0rpx rgba(0, 0, 0, 0.15);
		border-radius: 50%;
		overflow: hidden;
		// background-color: #FFFFFF;
	}

	/* 瀑布流*/
	.product__item {
		background-color: #FFFFFF;
		overflow: hidden;
		margin: 0 10rpx;
		margin-bottom: 20rpx;
		position: relative;
		// box-shadow: 0rpx 0rpx 30rpx 0rpx rgba(0, 0, 0, 0.07);

		.cha {
			width: 50rpx;
			height: 50rpx;
			position: absolute;
			top: 10rpx;
			right: 10rpx;
			background: #000;
			border-radius: 50%;
			display: flex;
			align-items: center;
			justify-content: center;
			.btn_close {
			    width: 30rpx;
			    height: 30rpx;
			}
		}

		.item {

			/* 图片 start */
			&__image {
				width: 100%;
				height: auto;
				background-color: #FFFFFF;
				border: 1rpx solid #F8F7F8;
				border-radius: 10rpx;
				overflow: hidden;
			}

			/* 图片 end */

			/* 内容 start */
			&__data {
				padding: 14rpx 0rpx;
			}

			/* 标题 start */
			&__title-container {
				text-align: justify;
				line-height: 38rpx;
				vertical-align: middle;
			}

			&__store-type {
				height: 28rpx;
				font-size: 20rpx;
				position: relative;
				display: inline-flex;
				align-items: center;
				justify-content: center;
				padding: 4rpx;
				border-radius: 6rpx;
				white-space: nowrap;
				text-align: center;
				top: -2rpx;
				margin-right: 6rpx;
			}

			&__title {
				font-size: 30rpx;
			}

			/* 标题 end */

			/* 标签 start */
			&__tags-container {
				display: flex;
				flex-direction: row;
				flex-wrap: nowrap;
				align-items: center;
				justify-content: flex-start;
			}

			&__tag {
				margin: 10rpx;
				color: #7C8191;
				background-color: #F3F2F7;
				padding: 4rpx 14rpx 6rpx;
				border-radius: 10rpx;
				font-size: 20rpx;

				&:first-child {
					margin-left: 0rpx !important;
				}
			}

			/* 标签 end */

			/* 价格 start */
			&__price-container {
				font-size: 24rpx;
				color: #E83A30;
				font-weight: bold;
			}

			&__price {
				&--unit {}

				&--integer {
					font-size: 38rpx;
				}

				&--decimal {}
			}

			/* 价格 end */
			/* 内容 end */
		}
	}
</style>